import request from '@/api/request'
import { downloadFile, uploadFile, getApiUrl } from '@/api/download'
import g from "@/utils/utilFn";
export function getlist(param) {
    param = g.objEngraving({
        asset_type: "",
        device_no: "",
        brand_model: "",
        worth: "",
        user: "",
        card_1: "",
        card_2: "",
        page: 1,
        limit: 10,
        filed: 'id',
        sort: 'ascending'
    }, param || {})
    let data = new FormData()
    Object.keys(param).map((key) => {
        data.append(key, param[key] || "");
    });
    return request({
        url: '/adm_mbdevice/getlist',
        method: 'POST',
        data
    })
}

export function remove_by_id(id) {
    let data = new FormData()
    data.append("id", id || "");
    return request({
        url: '/adm_mbdevice/delete_by_id',
        method: 'POST',
        data
    })
}

export function isexist_num(phone_num) {
    let data = new FormData()
    data.append("phone_num", phone_num || "");
    return request({
        url: '/adm_cart/isExist_num',
        method: 'POST',
        data
    })
}

export function getOneByNum(phone_num) {
    let data = new FormData()
    data.append("phone_num", phone_num || "");
    return request({
        url: '/adm_cart/getOneByNum',
        method: 'POST',
        data
    })
}


export function notExistAdd(param) {
    param = g.objEngraving({
        asset_type: "",
        device_no: "",
        brand_model: "",
        worth: "",
        user: "",
        card_1: "",
        card_2: "",
    }, param || {})
    let data = new FormData()
    Object.keys(param).map((key) => {
        data.append(key, param[key] || "");
    });
    return request({
        url: '/adm_mbdevice/notExistAdd',
        method: 'POST',
        data
    })
}
export function update(param) {
    param = g.objEngraving({
        id: "",
        asset_type: "",
        device_no: "",
        brand_model: "",
        worth: "",
        user: "",
        card_1: "",
        card_2: "",
    }, param || {})
    let data = new FormData()
    Object.keys(param).map((key) => {
        data.append(key, param[key] || "");
    });
    return request({
        url: '/adm_mbdevice/update',
        method: 'POST',
        data
    })
}


export function down_model() {
    var fileName = "model_d552c516-3519-11ef-a12f-00163e0acd8d.xls"
    downloadFile(fileName, "手机信息模板.xls")
}
export const up_load_url = getApiUrl('/file/up_file/mbdevice_model.xls')

export function batch_processing(random) {
    let data = new FormData()
    data.append("random", random);
    return request({
        url: '/adm_mbdevice/batch_processing/mbdevice_model.xls',
        method: 'POST',
        data
    })
}